<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<%@taglib prefix="shiro" uri="http://shiro.apache.org/tags"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<!DOCTYPE HTML>
<html>
<head>
<base href="<%=basePath%>">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>承接校验阶段</title>
<link rel="stylesheet" href="css/bootstrap.css">
<link rel="stylesheet" href="js/bootstrap2/css/bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="js/webuploader-0.1.5/webuploader.css" />
<link rel="stylesheet" href="css/vivo.css">
<link rel="stylesheet" href="css/common.css">


<script src="js/jquery-1.11.1.js"></script>
<script language="javascript" type="text/javascript" src="<%=basePath%>js/My97DatePicker/WdatePicker.js"></script>
<script type="text/javascript" src="js/webuploader-0.1.5/webuploader.js"></script>
<!-- 图片放大 -->
<script src="js/postbird-img-glass/postbird-img-glass.js"></script>
<script type="text/javascript" src="js/layui-v2.1.5/layui/layui.all.js"></script>

<script type="text/javascript" src="js/form.js"></script>
<script src="js/sharefunction.js"></script>

<style type="text/css">
.tdWidth {
	width: 100px;
}
</style>
<script type="text/javascript">
	$(function() {
		$("#continueForm").find("input,textarea").attr("readonly",true);
		$("#continueForm .Wdate").attr("disabled",true);
		$("#continueForm [name='remark']").attr("readonly",false);
		//初始化上传附件
		initWebUpload("filePicker_up", "list_up", "资料","fileHidden",fileSuccess, fileErr);
		//初始化表单
		mySubmit("continueForm", initContinue, successContinue);
		getFiles();
		
  		toolTip();
		//修改字段标记记录变量
		<c:set var="marks" value="原数据"/>
	});
</script>
</head>
<body>
	<div>
		<form id="continueForm" action="project/approval/addContinueStagePending" method="post" >
			<!-- 文件文本域 -->
			<input type="hidden" id="fileHidden" >
			<div class="panel panel-default">
				<div class="panel-heading">
					<h5 class="panel-title">承接查验阶段</h5>
				</div>
				<div class="panel-body">
					<table cellpadding="10" cellspacing="5" class="mytable">
						<tr>
							<td width="100px">承接查验时间</td>
							<td>
								<input name="checkDate" class="Wdate" onClick="WdatePicker({dateFmt:'yyyy-MM-dd'})" value="<fmt:formatDate value="${requestScope.checkStage.checkDate }" pattern="yyyy-MM-dd" />" />
								<c:if test="${not empty requestScope.map.checkDate }"><span class="toolTip mark-msg"data-tip="${requestScope.map.checkDate}">
									<c:out value="${marks}"/></span>
								 </c:if>
								 <c:if test="${requestScope.map.checkDate=='' }"><span class="toolTip mark-msg"data-tip="空">
									<c:out value="${marks}"/></span>
								</c:if>
							</td>
							<td width="100" align="right">项目名称</td>
							<td>
								<input name="checkName"  value="${requestScope.checkStage.checkName }"  />
								<c:if test="${not empty requestScope.map.checkName }"><span class="toolTip mark-msg"data-tip="${requestScope.map.checkName}">
									<c:out value="${marks}"/></span>
								 </c:if>
								 <c:if test="${requestScope.map.checkName=='' }"><span class="toolTip mark-msg"data-tip="空">
									<c:out value="${marks}"/></span>
								</c:if>
							</td>
						</tr>
						<tr>
							<td>资料</td>
							<td width="250px">
								<input name="checkScope" value="${requestScope.checkStage.checkScope }" />
								<c:if test="${not empty requestScope.map.checkScope }"><span class="toolTip mark-msg"data-tip="${requestScope.map.checkScope}">
									<c:out value="${marks}"/></span>
								 </c:if>
								 <c:if test="${requestScope.map.checkScope=='' }"><span class="toolTip mark-msg"data-tip="空">
									<c:out value="${marks}"/></span>
								</c:if>
							</td>
							<td>
								<div id="filePicker_up" style="display:none;">上传</div>
							</td>
						</tr>
						<tr>
							<td colspan="3">
								<div id="list_up"></div>
							</td>
						</tr>
					</table>
					
				</div>
			</div>
			<input value="${requestScope.checkStage.id }" hidden="hidden" id = "entityId_id" name="entityId_id"/>
			<c:if test="${requestScope.notPassExamine}">
				<!-- 修改时添加变更说明 -->
				<div id="remark" >
					审批说明： <textarea rows="3" style="width: 70%" name="remark"></textarea><span style="color:red;">*</span>
				</div>
				<div style="width:100%;text-align:center; padding-top:20px">
					
					<!-- 保存状态 -->
					<button class="btn btn-danger radius"
						onClick="saveCheck(1);" type="button">同意</button>
					<button class="btn btn-default radius"
						onClick="saveCheck(0);" type="button">拒绝</button>
				</div>
			</c:if>
			<input name="exDataId" id="exDataId" hidden="hidden" value="${requestScope.exDataId }">
			<input name="pendingId" id="pendingId" hidden="hidden" value="${requestScope.pendingId }">
		</form>
	</div>
</body>
<script type="text/javascript">
	
	//上传成功 初始化图片放大
	function fileSuccess() {
		PostbirdImgGlass.init({
			domSelector : "#list_up img",
			animation : true,
			myDocument : top
		});
	}
	function fileErr() {
		alert("图片上传失败");
	}
	//封装上传参数
	function initContinue(){
		var remark = $("#continueForm [name='remark']").val();//变更意见
		var remark = $("#continueForm [name='remark']").val();
		var pendingId = $("#continueForm [name='pendingId']").val();
		var exDataId = $("#continueForm [name='exDataId']").val();
		var i = layer.load(2);
		if(remark==""){
			layer.alert("审批意见不能为空");
			layer.close(i);
			return null;
		}else{
			
			return {
				remark : remark,//编辑时填写备注
				pendingId : pendingId,
				spFlag :spFlag,
				exDataId:exDataId
			}
		}
	}
	//提交回调
	function successContinue(data){
		if(data){
			layer.alert("保存成功", {
	       		offset:'20%',
	       		shade:[0.1,'#fff']
			}, function() {
				parent.location.reload();
				parent.parent.getPendingCount();
				parent.parent.getPendingPassCount();
				parent.parent.getPendingBackCount();
			});
		}else{
			alert("保存失败", {icon: 7});
			layer.closeAll();
		}
	}
	
	//展示附件  
	function getFiles() {
	  getFileListByFlag($("#continueForm #entityId_id").val(), "资料", 2,"#list_up", setRFL, imgPlus);
	  <c:if test="${requestScope.notPassExamine}"> 
	  //编辑时提交的临时附件
		//添加编辑时的临时附件数据
		var caList=[${requestScope.caList}];
		if(caList.length > 0){
			var erul = "";//资料id
			for(var i=0;i<caList.length;i++){
				erul += (","+caList[i].accessoryCAId);
			}
			if(erul != ""){
				getFileTempList(erul.substring(1),"#list_up",setRFL,imgPlus);
			}
		}
		</c:if>
	}
	 function imgPlus(data) {
		$("#continueForm .uploadcancel").css("display", "none");
		$.each(data, function(i, v) {
			//图片放大
			PostbirdImgGlass.init({
				domSelector : "#" + v.id + " img",
				animation : true,
				myDocument : window.parent.parent.parent
			});
		});
	}
	var rFileList = new Array(); //
	//设置待删除附件的值到集合中
	function setRFL(id, _this) {
		layer.confirm('删除该图片？', {
			title : '警告',
			icon : 0,
			shade : [ 0.1, '#fff' ]
		}, function() {
			rFileList.push(id);
			//rFileList=id+","+rFileList
			//删除指定缩略图
			$("#" + id).remove();
			layer.close(layer.index);
		});
	}
	//启用编辑
	var spFlag;//记录编辑还是新增的状态
	function saveCheck(val){
		spFlag = val;
		$("#continueForm").submit();
	}
	
</script>
</html>